var http = require('http');
var bodyParser = require("body-parser");  
var express = require('express');
var path = require('path');
var app = express();
var config = require('./config/config.json');
var services = require('./server/services.js');
var log = require('./server/log.js');  
var publicstring = path.join(__dirname, 'public');
log.use(app); 

//使用bodyParser
app.use(bodyParser.urlencoded({
  extended: true
}));
app.use(bodyParser.json({
  extended: true
}));

app.use(express.static(publicstring)); //设置静态目录
var router = new services(config).router(express);
app.use('/war', router);
app.listen(config.http.port, /*config.http.host, */ function() {
	// print a message when the server starts listening
	console.log("服务器启动成功，监听端口为：" + config.http.port);
	var logger = require('./server/log.js').logger; 
    logger.info("服务器启动成功，监听端口为：" + config.http.port);  
});